package basic.study.wantOffer.chapter3;

/**
 * @ClassName Problem28
 * @Description 对称的二叉树
 * @Company inspur
 * @Author Kevin
 * @Date 2020/5/15 10:14
 * @Version 1.0
 */
public class Problem28 {
    boolean isSymmetrical(BinaryTreeNode root) {
        return isSymmetrical(root, root);
    }

    private boolean isSymmetrical(BinaryTreeNode root1, BinaryTreeNode root2) {
        if (root1 == null && root2 == null) {
            return true;
        }
        if (root1 == null || root2 == null) {
            return false;
        }
        if (root1.value != root2.value) {
            return false;
        }
        return isSymmetrical(root1.left, root2.left) && isSymmetrical(root1.right, root2.right);
    }
}
